/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package pe.edu.unmsm.cinfo.siga.datos;

import java.io.Serializable;
import java.util.Date;
import javax.persistence.Column;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.xml.bind.annotation.XmlRootElement;

/**
 *
 * @author alumno
 */
@Entity
@Table(name = "HORARIO_PER")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "HorarioPersonal.findAll", query = "SELECT h FROM HorarioPersonal h"),
    @NamedQuery(name = "HorarioPersonal.findByPerCod", query = "SELECT h FROM HorarioPersonal h WHERE h.horarioPersonalPK.perCod = :perCod"),
    @NamedQuery(name = "HorarioPersonal.findByDiaCod", query = "SELECT h FROM HorarioPersonal h WHERE h.horarioPersonalPK.diaCod = :diaCod"),
    @NamedQuery(name = "HorarioPersonal.findByHorIni", query = "SELECT h FROM HorarioPersonal h WHERE h.horIni = :horIni"),
    @NamedQuery(name = "HorarioPersonal.findByHorFin", query = "SELECT h FROM HorarioPersonal h WHERE h.horFin = :horFin"),
    @NamedQuery(name = "HorarioPersonal.findByTurnos", query = "SELECT h FROM HorarioPersonal h WHERE h.turnos = :turnos")})
public class HorarioPersonal implements Serializable {
    private static final long serialVersionUID = 1L;
    @EmbeddedId
    protected HorarioPersonalPK horarioPersonalPK;
    @Column(name = "HOR_INI")
    @Temporal(TemporalType.TIME)
    private Date horIni;
    @Column(name = "HOR_FIN")
    @Temporal(TemporalType.TIME)
    private Date horFin;
    @Column(name = "TURNOS")
    private Short turnos;
    @JoinColumn(name = "PER_COD", referencedColumnName = "PER_COD", insertable = false, updatable = false)
    @ManyToOne(optional = false, fetch = FetchType.LAZY)
    private Personal personal;
    @JoinColumn(name = "DIA_COD", referencedColumnName = "DIA_COD", insertable = false, updatable = false)
    @ManyToOne(optional = false, fetch = FetchType.LAZY)
    private Dia dia;

    public HorarioPersonal() {
    }

    public HorarioPersonal(HorarioPersonalPK horarioPersonalPK) {
        this.horarioPersonalPK = horarioPersonalPK;
    }

    public HorarioPersonal(int perCod, int diaCod) {
        this.horarioPersonalPK = new HorarioPersonalPK(perCod, diaCod);
    }

    public HorarioPersonalPK getHorarioPersonalPK() {
        return horarioPersonalPK;
    }

    public void setHorarioPersonalPK(HorarioPersonalPK horarioPersonalPK) {
        this.horarioPersonalPK = horarioPersonalPK;
    }

    public Date getHorIni() {
        return horIni;
    }

    public void setHorIni(Date horIni) {
        this.horIni = horIni;
    }

    public Date getHorFin() {
        return horFin;
    }

    public void setHorFin(Date horFin) {
        this.horFin = horFin;
    }

    public Short getTurnos() {
        return turnos;
    }

    public void setTurnos(Short turnos) {
        this.turnos = turnos;
    }

    public Personal getPersonal() {
        return personal;
    }

    public void setPersonal(Personal personal) {
        this.personal = personal;
    }

    public Dia getDia() {
        return dia;
    }

    public void setDia(Dia dia) {
        this.dia = dia;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (horarioPersonalPK != null ? horarioPersonalPK.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof HorarioPersonal)) {
            return false;
        }
        HorarioPersonal other = (HorarioPersonal) object;
        if ((this.horarioPersonalPK == null && other.horarioPersonalPK != null) || (this.horarioPersonalPK != null && !this.horarioPersonalPK.equals(other.horarioPersonalPK))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "pe.edu.unmsm.cinfo.siga.datos.HorarioPersonal[ horarioPersonalPK=" + horarioPersonalPK + " ]";
    }
    
}
